package com.tangtanwei.hotel.controller;

import com.tangtanwei.hotel.entity.Room;
import com.tangtanwei.hotel.entity.dto.RoomQueryDto;
import com.tangtanwei.hotel.service.RoomService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/room")
public class RoomController {


    private final RoomService roomService;

    public RoomController(RoomService roomService) {
        this.roomService = roomService;
    }

    //根据房间id删除房间
    @RequestMapping("/delete")
    public String deleteUserById(String id){
        return roomService.removeById(id) ? "删除成功": "删除失败";
    }

    // 根据id获取房间
    @RequestMapping("/getOne")
    public Room getOneById(String id){
        return roomService.getById(id);
    }


    // 保存或者修改
    @RequestMapping("/saveOrupdate")
    public String saveOrupdate(Room room){
        return roomService.saveOrupdate(room);
    }

    // 搜索房间
    @RequestMapping("/search")
    public List<Room> search(String keyword){
        return roomService.search(keyword);
    }

    // 筛选房间
    @RequestMapping("/condition")
    public List<Room> getByCondition(RoomQueryDto roomQueryDto){
        return roomService.getByCondition(roomQueryDto);
    }




}
